package com.mcptt.db.loader.msg;

import android.annotation.TargetApi;
import android.content.Context;
import android.database.Cursor;
import android.os.Build;

import com.cloudptt.api.product.log.Log;
import com.mcptt.db.Callback;
import com.mcptt.db.DBAdapter;
import com.mcptt.db.model.AddrInfo;
import com.mcptt.db.model.SessionInfo;

import java.util.List;
import java.util.Vector;

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class SessionFuncListLoader implements Callback
{
//	private final static String THIS_FILE = "MsgListLoader";
	private Context ctx = null;
//	private AddrInfo fromInfo = null;
	private SessionListLoaderCb callback = null;
	public SessionFuncListLoader(Context ctx, DBAdapter dbOperater, SessionListLoaderCb callback)
	{
		this.ctx = ctx;
		this.callback = callback;
//		dbOperater.queryLargeFuncSessionList(this);
	}


	@Override
	public void onDataFetched(Cursor data) {
		if (data == null
				|| data.getCount() < 0)
		{
			return;
		}
		Log.debug(this.getClass(),"onLoadFinished Cursor.getCount() = " + data.getCount());
		List<SessionInfo> list = new Vector<SessionInfo>();
		Cursor cursor = data;
		while (cursor.moveToNext())
		{
			SessionInfo info = new SessionInfo(cursor);
			list.add(info);
		}
		cursor.close();
		cursor = null;

		this.callback.onLoadFinished(list);
	}
}
